module App::Controller
    class TrayIcon < Qt::Object
        slots 'trayIconActivated(QSystemTrayIcon::ActivationReason)'

        attr_reader :view
        
        def initialize(model)
            super()

            @view = App::View::TrayIcon.new
            Qt::Object.connect @view, SIGNAL('activated(QSystemTrayIcon::ActivationReason)'),
                                      self, SLOT('trayIconActivated(QSystemTrayIcon::ActivationReason)')
            #@view.setAcceptDrops(true)

            connect(model.watchdog, SIGNAL('taskRunning(QObject*, int)'),
                @view, SLOT('taskRunning(QObject*, int)'))
            connect(model.watchdog, SIGNAL('taskStopped()'),
                @view, SLOT('task_stopped()'))
        end
        
        private
        def trayIconActivated(why)
            #puts "TRAY", why
            $widget.trayIconActivated
        end

        # egyelore nincs tamogatva
        def dragEnterEvent(event)
            event.acceptProposedAction()
        end
        def dragMoveEvent(event)
            event.acceptProposedAction()
        end
        def dropEvent(event)
            mimeData = event.mimeData()
            if mimeData.hasText
                puts "got text!", mimeData.text
            end
            event.acceptProposedAction()
        end
        def dragLeaveEvent(event)
            event.accept()
            # emit if done
        end
    end
end
